//
//  PS_BaseViewController.m
//  PolicySystem
//
//  Created by 丹丹 on 2018/10/24.
//  Copyright © 2018年 xuezi. All rights reserved.
//

#import "PS_BaseViewController.h"

@interface PS_BaseViewController ()

@end

@implementation PS_BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGBCOLOR(238, 238, 238);

    [self customNav];
    // Do any additional setup after loading the view.
}
- (void)customNav{
    
    //1、隐藏自带的导航 底部view
    self.navigationController.navigationBar.hidden=YES;
    
    if (@available(iOS 11.0, *)) {
        
        [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    }
    
    //2、自定义导航栏底部   颜色值 243 92 20
    self.nav_btmView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SafeAreaTopHeight)];
    self.nav_btmView.backgroundColor =[UIColor clearColor];
    [self.view addSubview:self.nav_btmView];
    
    self.nav_btmImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SafeAreaTopHeight)];
    self.nav_btmImage.image = [UIImage imageNamed:@"beijingqqqqqq"];
    self.nav_btmImage.userInteractionEnabled = YES;
    [self.nav_btmView addSubview:self.nav_btmImage];
    
    //2.添加状态栏
    self.statusBarView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, kStatusBarHeight)];
    self.statusBarView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.statusBarView];
    
    
    // 3、 创建标题
    self.nav_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight-44, SCREEN_WIDTH, 44)];
    self.nav_titleLabel.textAlignment = NSTextAlignmentCenter;
    self.nav_titleLabel.textColor = [UIColor whiteColor];
    self.nav_titleLabel.font =[UIFont boldSystemFontOfSize:18.0f];
    self.nav_titleLabel.font =[UIFont fontWithName:Font_Name size:18.0];
    [self.nav_btmView addSubview:self.nav_titleLabel];
    
    //创建返回按钮image
    self.nav_backImg =[[UIImageView alloc]initWithFrame:CGRectMake(14, kStatusBarHeight+(44-20)/2, 12, 20)];
    self.nav_backImg.backgroundColor =ClearColor;
    self.nav_backImg.clipsToBounds =YES;
    self.nav_backImg.contentMode =UIViewContentModeScaleAspectFit;
    self.nav_backImg.image  = [UIImage imageNamed:@"fanhuianniu"];
    [self.nav_btmView addSubview:self.nav_backImg];
    
    //创建返回按钮
    self.nav_backButton =[[UIButton alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight-44, 50, 44)];
    self.nav_backButton.titleLabel.font =[UIFont systemFontOfSize:14.0];
    self.nav_backButton.titleLabel.textAlignment =NSTextAlignmentLeft;
    [self.nav_backButton addTarget:self action:@selector(backButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.nav_btmView addSubview:self.nav_backButton];
    
    
    //创建右侧按钮image
    self.nav_rightImg =[[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-50, kStatusBarHeight+(44-25)/2, 25, 25)];
    self.nav_rightImg.backgroundColor =ClearColor;
    self.nav_rightImg.clipsToBounds =YES;
    self.nav_rightImg.contentMode =UIViewContentModeScaleAspectFit;
    [self.nav_btmView addSubview:self.nav_rightImg];
    self.nav_rightImg.hidden =YES;
    
    self.noreadImage = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.nav_rightImg.frame), kStatusBarHeight+(44-25)/2, 10, 10)];
    self.noreadImage.layer.cornerRadius = 5;
    self.noreadImage.backgroundColor=[UIColor whiteColor];
    self.noreadImage.hidden = YES;
    [self.nav_btmView addSubview:self.noreadImage];
    
    // 创建导航栏右侧第一按钮
    self.nav_rightButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-80, SafeAreaTopHeight-44, 60, 44)];
    self.nav_rightButton.backgroundColor =[UIColor clearColor];
    [self.nav_rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.nav_rightButton.titleLabel.font =[UIFont systemFontOfSize:15.0];
    self.nav_rightButton.titleLabel.textAlignment =NSTextAlignmentRight;
    [self.nav_rightButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
    self.nav_rightButton.hidden= YES;
    [self.nav_btmView addSubview:self.nav_rightButton];
    
    
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
    
    self.automaticallyAdjustsScrollViewInsets =NO;
}

- (void)backButtonClick {
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
